﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Client/ClientMaster.Master" AutoEventWireup="true" 
	CodeBehind="Documents.aspx.cs" Inherits="FRL.DebtChased.Website.ClientZone.Documents" Theme="BaselineTheme" %>

<%@ Register src="~/Controls/PageHeadingBarCtrl.ascx" tagname="PageHeadingBarCtrl" tagprefix="uc1" %>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
.addButtonStyle
{
	margin:4px;
	margin-right:82px;
	Width:58px;
}
</style>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<!-- Heading bar -->
<div style="margin:auto; margin-top:0px; width:840px;">
	<uc1:PageHeadingBarCtrl ID="pageHeadingBarCtrl" runat="server" Title="Documents" />
</div>

<!-- Results -->
<asp:Panel runat="server" CssClass="panelStyle840" ID="pnlResults">
	<asp:GridView ID="gridResult" runat="server" AutoGenerateColumns="False" CssClass="SilverGridView"
		HorizontalAlign="Center" DataKeyNames="DocumentId"
		onrowcommand="gridResult_RowCommand" BorderStyle="None" 
		onrowdatabound="gridResult_RowDataBound" GridLines="Horizontal" >
		<Columns>

			<asp:BoundField DataField="DocumentName" HeaderText="Document Name">
				<HeaderStyle HorizontalAlign="Left" />
				<ItemStyle Width="380px" VerticalAlign="Top" />
			</asp:BoundField>

			<asp:BoundField DataField="BytesAsText" HeaderText="Size">
				<HeaderStyle HorizontalAlign="Center" />
				<ItemStyle Width="80px" VerticalAlign="Top" HorizontalAlign="Center" />
			</asp:BoundField>

			<asp:HyperLinkField Text="Download" DataNavigateUrlFields="DownloadUrl" Target="_blank">
				<ItemStyle Width="80px" HorizontalAlign="Center" />
			</asp:HyperLinkField>

			<asp:TemplateField>
				<ItemTemplate>
					<asp:Button Text="Delete" runat="server" ID="butDeleteDocument" OnClick="butDeleteDocument_Click" />
				</ItemTemplate>
			</asp:TemplateField>

			<asp:CommandField SelectText="Select" ButtonType="Button" ShowSelectButton="true">
				<ItemStyle Width="70px" HorizontalAlign="Center" />
			</asp:CommandField>

		</Columns>
		<EmptyDataTemplate>
			<asp:Label ID="Label1" runat="server" Text="No documents found" CssClass="SilverLabel" />
		</EmptyDataTemplate>
	</asp:GridView>
	<div style="text-align:left; padding-left:80px;">
		<asp:Button runat="server" Text="Add" ID="butAdd" onclick="butAdd_Click" CssClass="SilverButton" />
	</div>
</asp:Panel>

<!-- Add -->
<asp:Panel runat="server" CssClass="panelStyle840" ID="pnlAdd" HorizontalAlign="Right">
	<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
		<ContentTemplate>
		<table border="0" style="margin-left:40px; text-align:left;">
			<tr>
				<td class="SilverLabel">File:</td>
				<td><asp:FileUpload Width="430px" ID="fileUpload" runat="server" class="SilverFileUpload" /></td>
			</tr>
			<tr>
				<td></td>
				<td><asp:CheckBox CssClass="SilverCheckBox" ID="chkConvertToPDF" runat="server" Text="Convert all documents to PDF" /></td>
			</tr>
			<tr>
				<td></td>
				<td style="text-align:left;">
					<asp:Button Text="OK" runat="server" ID="butOKAdd" onclick="butOKAdd_Click" class="SilverButton" Width="82px" />&nbsp;
					<asp:Button Text="Cancel" CausesValidation="false" runat="server" ID="butCancelAdd" OnClick="butCancelAdd_Click" class="SilverButton" Width="82px" />
				</td>
			</tr>
		</table>
		</ContentTemplate>
		<Triggers>
			<asp:PostBackTrigger ControlID="butOKAdd" />
		</Triggers>
	</asp:UpdatePanel>
</asp:Panel>

<!-- Edit -->
<asp:Panel runat="server" CssClass="panelStyle840" ID="pnlEdit" HorizontalAlign="Right">
	<asp:UpdatePanel ID="updFields" runat="server" UpdateMode="Always">
		<ContentTemplate>
		<table border="0">
			<tr>
				<td class="SilverLabel">Document Name:</td>
				<td style="text-align:left;">
					<asp:TextBox Width="430px" ID="txtDocumentName" runat="server" class="SilverTextBox" />
					<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" CssClass="SilverValidation" ControlToValidate="txtDocumentName" ValidationGroup="editGroup"
					ErrorMessage="(enter a document name)"></asp:RequiredFieldValidator>
				</td>
			</tr>
			<tr>
				<td class="SilverLabel" style="vertical-align:top;">Attached Invoices:</td>
				<td>
					<asp:GridView runat="server" ID="gridInvoice" AutoGenerateColumns="false" BorderStyle="None" 
						DataKeyNames="AccountInvoiceId" CssClass="SilverGridView" 
						onrowcommand="gridInvoice_RowCommand">
						<RowStyle HorizontalAlign="Left" />
						<HeaderStyle HorizontalAlign="Left" />
						<Columns>
							<asp:BoundField DataField="FRLRef" HeaderText="FRL Reference">								
								<HeaderStyle HorizontalAlign="Left" />
								<ItemStyle Width="130px" />
							</asp:BoundField>

							<asp:BoundField DataField="ClientRef" HeaderText="Client Reference">								
								<HeaderStyle HorizontalAlign="Left" />
								<ItemStyle Width="140px" />
							</asp:BoundField>

							<asp:BoundField DataField="InvoiceNo" HeaderText="Invoice">								
								<HeaderStyle HorizontalAlign="Left" />
								<ItemStyle Width="80px" />
							</asp:BoundField>

							<asp:BoundField DataField="AmountAsText" HeaderText="Amount">								
								<HeaderStyle HorizontalAlign="Left" />
								<ItemStyle Width="80px" />
							</asp:BoundField>
								
							<asp:CommandField SelectText="Remove" ButtonType="Button" ShowSelectButton="true">
								<ItemStyle Width="70px" HorizontalAlign="Center" />
							</asp:CommandField>

						</Columns>
						<EmptyDataTemplate>
							<asp:Label class="SilverLabel" runat="server" Text="No invoices are attached to this document." />
						</EmptyDataTemplate>
					</asp:GridView>
				</td>
			</tr>
			<tr>
				<td class="SilverLabel">Account Ref:</td>
				<td style="text-align:left;">
					<asp:TextBox runat="server" ID="txtSearchAccRef" />&nbsp;<asp:Button runat="server" ID="butSearchAccRef" Text="Search" onclick="butSearchAccRef_Click" ValidationGroup="searchGroup" />
					<asp:RequiredFieldValidator ID="rfvSearchAccRef" runat="server" ControlToValidate="txtSearchAccRef"
						 CssClass="SilverValidation" ValidationGroup="searchGroup"
						ErrorMessage="(Enter a search reference)"></asp:RequiredFieldValidator>
				</td>
			</tr>
			<tr>
				<td></td>
				<td style="text-align:left;"><asp:Label runat="server" class="SilverInstructions" Text="(enter an FRL or client account reference)" /></td>
			</tr>
			<tr>
				<td class="SilverLabel" style="vertical-align:top;">Search Results:</td>
				<td>
					<asp:GridView runat="server" ID="gridAvailable" AutoGenerateColumns="false" DataKeyNames="AccountInvoiceId" CssClass="SilverGridView" BorderStyle="None" 
						onrowcommand="gridAvailable_RowCommand">
						<RowStyle HorizontalAlign="Left" />
						<HeaderStyle HorizontalAlign="Left" />
						<Columns>

							<asp:BoundField DataField="FRLRef" HeaderText="FRL Reference">								
								<HeaderStyle HorizontalAlign="Left" />
								<ItemStyle Width="130px" />
							</asp:BoundField>

							<asp:BoundField DataField="ClientRef" HeaderText="Client Reference">								
								<HeaderStyle HorizontalAlign="Left" />
								<ItemStyle Width="140px" />
							</asp:BoundField>

							<asp:BoundField DataField="InvoiceNo" HeaderText="Invoice">								
								<HeaderStyle HorizontalAlign="Left" />
								<ItemStyle Width="80px" />
							</asp:BoundField>

							<asp:BoundField DataField="AmountAsText" HeaderText="Amount">								
								<HeaderStyle HorizontalAlign="Left" />
								<ItemStyle Width="80px" />
							</asp:BoundField>

							<asp:CommandField SelectText="Attach" ButtonType="Button" ShowSelectButton="true">
								<ItemStyle Width="70px" HorizontalAlign="Center" />
							</asp:CommandField>

						</Columns>
						<EmptyDataTemplate>
							<asp:Label ID="Label2" class="SilverLabel" runat="server" Text="[No invoices found]" />
						</EmptyDataTemplate>
						
					</asp:GridView>
				</td>
			</tr>
			<tr>
				<td></td>
				<td>
					<asp:Button Text="OK" ValidationGroup="editGroup" runat="server" ID="butOKEdit" onclick="butOKEdit_Click" class="SilverButton" />&nbsp;
					<asp:Button Text="Cancel" CausesValidation="false" runat="server" ID="butCancelEdit" OnClick="butCancelEdit_Click" class="SilverButton" />
				</td>
			</tr>
		</table>
		</ContentTemplate>
		<Triggers>
			<asp:PostBackTrigger ControlID="butOKEdit" />
		</Triggers>
	</asp:UpdatePanel>
</asp:Panel>

</asp:Content>
